class Solution
{
public:
    vector<int> answerQueries(vector<int> &nums, vector<int> &queries)
    {
        sort(nums.begin(), nums.end());
        partial_sum(nums.begin(), nums.end(), nums.begin());
        vector<int> result;
        for (int query : queries)
        {
            result.push_back(upper_bound(nums.begin(), nums.end(), query) - nums.begin());
        }
        return result;
    }
};